from django.db import models
from user.models import JobInfo
from home.models import DeliverJobposting,Jobposting


#   简历解析后的结构化数据
class ResumeParseData(models.Model):
    jobsposting = models.ForeignKey(Jobposting, on_delete=models.CASCADE, verbose_name='职位信息',related_name='job_resume')
    jobinfo = models.ForeignKey(JobInfo, on_delete=models.CASCADE, verbose_name='关联求职者', related_name='parsed_resumes')
    parse_text=models.TextField(verbose_name="解析后的纯文本")
    skills=models.JSONField(default=list, verbose_name='技能列表')
    work_experience=models.JSONField(default=list, verbose_name='工作经历')
    education = models.CharField(max_length=50,default='',verbose_name='学历')
    create_time = models.DateTimeField(auto_now_add=True,verbose_name='解析时间')
    class Meta:
        db_table = 'resume_parse_data'


class Interview(models.Model):
    deliverjob = models.ForeignKey(DeliverJobposting, on_delete=models.CASCADE, verbose_name="投递记录")
    # 1. AI筛选结果存储
    ai_search_score = models.IntegerField(verbose_name="检索评分", default=0)
    ai_match_score = models.IntegerField(verbose_name="技能加分", default=0)
    ai_match_points = models.JSONField(verbose_name="AI匹配点", null=True)
    ai_risk_points = models.JSONField(verbose_name="AI风险点", null=True)
    # ai_screen_status = models.CharField(max_length=16, default='pending', verbose_name="AI筛选状态")  # passed/failed
    user_evaluation = models.TextField(null=True, blank=True, verbose_name="AI自然语言评价-user展示")
    hr_evaluation = models.TextField(null=True, blank=True, verbose_name="AI自然语言评价-hr展示")
    end_at = models.DateTimeField(null=True, blank=True, verbose_name="完成时间")

    class Meta:
        db_table = "interview"
